<script type="text/javascript">
function memProfile(member)
{
	window.location='index.php?members='+member;
}

function funDelMem(userId) {
	var delPro=confirm("Are you sure want to delete merchant?");
    if(delPro==true) {
		var frm = document.getElementById('form1');
		document.getElementById("hidDelMember").value=userId;
	    frm.submit();
	}	
}

function funAppMem(userId) {
	var delPro=confirm("Are you sure want to allow this merchant?");
    if(delPro==true) {
		var frm = document.getElementById('form1');
		document.getElementById("hidApprove").value=userId;
	    frm.submit();
	}	
}

function funDisAppMem(userId) {
	var delPro=confirm("Are you sure want to block merchant?");
    if(delPro==true) {
		var frm = document.getElementById('form1');
		document.getElementById("hidDisApprove").value=userId;
	    frm.submit();
	}	
}

</script>
<?php
if(!empty($_POST['hidApprove']))
{
	$mId=$_POST['hidApprove'];
	$sqlAppMem="Update tbl_users set status=1 where user_id='$mId'";
	$rstAppMem=mysql_query($sqlAppMem);	
}
if(!empty($_POST['delMember']))
{
	$memberId=$_POST['delMember'];
	$sqlDelMem="Delete from tbl_users where user_id=$memberId";
	$rstDelMem=mysql_query($sqlDelMem);	
}
?>
<form name="form1" id="form1" method="post" action="">
			  <input type="hidden" name="hidDelMember" id="hidDelMember">
			  <input type="hidden" name="hidApprove" id="hidApprove">
			  <input type="hidden" name="hidDisApprove" id="hidDisApprove">
			  
<table width="100%"  border="1" cellspacing="0" class="container">
  <tr>
    <td width="469" height="25" class="tdHeader">Members  List</td>
  </tr>
  <tr>
    <td height="577">
	<br><br>
	<table width="100%"  border="0" cellspacing="0">      
      <tr class="InnerHeader">       
        <td width="15%" class="line">Member type </td>
		<td width="21%" class="line">Member name </td>
        <td width="21%" class="line">First name </td>
        <td width="16%" class="line">Last name </td>
        <td width="9%" class="line">&nbsp;</td>
        <td width="8%" class="line">&nbsp;</td> 
		<td width="10%" class="line">&nbsp;</td>         
      </tr>     
      <?php 				 
				 require_once "../includes/pagination.php";
				 $itemPerPage=15;
				 $sql_shocat="SELECT * FROM tbl_users where user_type=3 and status=2";				 
				 $rst_shocat=mysql_query(getPagingQuery($sql_shocat,$itemPerPage));			
				 $numRows = mysql_num_rows($rst_shocat);
				 if($numRows>0) {
					 while($row_shocat = mysql_fetch_array($rst_shocat)) {				 
					 $mem_id=$row_shocat['user_id'];
					 $mem_name=$row_shocat['username'];
					 $usr_type=$row_shocat['user_type'];				 
					 $mem_fname=$row_shocat['first_name'];
					 $mem_lname=$row_shocat['last_name'];
					 echo "<tr>";
					 echo "<td class='line'>Merchant</td>";
					 echo "<td class='line'>$mem_name</td>";
					 echo "<td class='line'>$mem_fname</td>";
					 echo "<td class='line'>$mem_lname</td>";
					 echo "<td height='20' class='line'><input type='button' name='btnApprove' value='Approve' class='button'  onclick='funAppMem($mem_id)'></td> ";
					 echo "<td height='20' class='line'><input type='button' name='view' value='View' class='button'  onclick='memProfile($mem_id)'></td> ";
					 echo "<td height='20' class='line'><input type='button' name='delete' value='Delete' class='button'  onclick='funDelMem($mem_id)';></td> ";
					 echo "</tr>";
					
					 } 
				 } else {
				 	echo " <tr>
							<td colspan='7' class='line'>No new merchants found.</td>
							</tr>";
				 }				 
				 ?>      
       </table>
	<div align="center">
		<?php		   
		   $link="newmer";
		   echo $disp=getPagingLink($sql_shocat,$itemPerPage,$link);							   
		?>    
	</div>
	</td>
 </tr>
</table>